import java.util.*;
import java.io.*;
/**
 * Write a program that writes a starter program and stores it in a file.
   (Hint: see your FileOutputExample in your Examples project.)
 
   The filename should be the name of the class with ".java" appended.
   For example, if the user enters "MyProgram" for the classname,
   your program should use the filename, "MyProgram.java" (append ".java").
 
   When your program works properly, you can add the new class to BlueJ.
   Here's how:
   In BlueJ project window, on the Edit Menu select "Add Class from File",
   navigate to your new class and select "MyProgram.java" (or whatever
   filename you generated).
   Alternatively:
   You can also just restart BlueJ and it will find the new .java file.
 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class A17_1
{
   public static void main(String[] args) throws IOException
    {
        Scanner keyboard = new Scanner(System.in);
        System.out.print(
            "This program will generate a new program (a class) for you.\n" +
            "Enter the new class name (ex. MyProgram): ");
 
        String klass = keyboard.nextLine();
 
       PrintWriter writer = new PrintWriter(new File(klass + ".Java"));
       
       writer.println("public class " + klass + " {");
       writer.println("    public static void main(String[] args) {");
       writer.println("        System.out.println(\"Hello world!\");");
       writer.println(" }");
       writer.println("}");
       
       writer.close();
       System.out.println("File written");
    }
}
/*
 * my test session:
 * This program will generate a new program (a class) for you.
Enter the new class name (ex. MyProgram): MyProgram
File written

 */